const { musicInfoExist } = require('../constant/musiclikeErrortype')
const colletVaild = async (ctx, next) => {
    // const { user_id } = ctx.state.user
    try {
        const { id, coverImgUrl, name } = ctx.request.body
        if (!id || !coverImgUrl || !name) {
            return ctx.app.emit('error', musicInfoExist, ctx)
        }
        await next()
    } catch (error) {
    }
}
const colletidsVaild = async (ctx, next) => {
    try {
        const { id } = ctx.request.body
        if (!id) {
            return ctx.app.emit('error', musicInfoExist, ctx)
        }
        await next()
    } catch (error) {
    }
}

const ParamsVaild = async (ctx, next) => {
    try {
        const { pageNo, pageSize } = ctx.request.query
        if (!pageNo || !pageSize) {
            return ctx.app.emit('error', musicInfoExist, ctx)
        }
        await next()
    } catch (error) {
    }
}


module.exports = { colletVaild, colletidsVaild, ParamsVaild }